package de.fuberlin.processing.who.cancer.utils.graphics;

import processing.core.PStyle;


public class RingSegmentStyle {
	
	PStyle style;
	int startSegment;
	int endSegment;
	
	
	public RingSegmentStyle( PStyle style, int startSegment, int endSegment) {
		this.style = style;
		this.startSegment = startSegment;
		this.endSegment = endSegment;
	}
	
	public static RingSegmentStyle[] add( RingSegmentStyle[] styles, PStyle nextSegmentStyle, int nextSegmentStart) {
		RingSegmentStyle[] result;
		if ( styles == null || styles.length == 0) {
			result = new RingSegmentStyle[1];
			result[0] = new RingSegmentStyle( nextSegmentStyle, nextSegmentStart, nextSegmentStart); 
		} else {
			result = new RingSegmentStyle[styles.length +1];
		  System.arraycopy( styles, 0, result, 0, styles.length);
		  int nextSegmentEnd = result[result.length -2].endSegment;
		  result[result.length -2].endSegment = nextSegmentStart;
		  result[result.length -1] = new RingSegmentStyle( nextSegmentStyle, nextSegmentStart, nextSegmentEnd); 
		}
    return result;
	}

}
